\ProvidesPackage{omnencap}

%% listings does the basic layout of the code, and syntax highlighting. 
\RequirePackage{listings}
%% add manchester syntax specific syntax information.
\RequirePackage{omn}




%% These are the inclusion macros. They all have the same pattern, but I don't
%% know enough about latex to do this in a macro. 
%% \csname allows me to invoke a macro with non-letter characters in it. 
%% These are the main user interface for omnencap. 
\newcommand{\omnheader}{\OmnEntityHeader}
\newcommand{\omnclass}[2]{
  \OmnDoEntity{Class}{#1}{#2}
}
\newcommand{\omnobjprop}[2]{
  \OmnDoEntity{ObjectProperty}{#1}{#2}
}
\newcommand{\omndataprop}[2]{
  \OmnDoEntity{DataProperty}{#1}{#2}
}
\newcommand{\omnindividual}[2]{
  \OmnDoEntity{Individual}{#1}{#2}
}


%% csname expands the thing after to a token, which is equivalent to \relax if
%% if doesn't exist. So first check whether the token exists, crash if it
%% doesn't, and if it does, call the token, so that it is expanded in text
\newcommand{\OmnDoEntity}[3]{
  \expandafter\ifx
  \csname OmnEntity#1#2#3\endcsname
  \relax
  \@latex@error{Unknown entity: #2:#3}\@ehc
  \else
  \csname OmnEntity#1#2#3\endcsname
  \fi
}

%% This code provides support for the summary. These commands are not user
%% facing, but are providing of \omnsummary. The first set are text, and later
%% ones numerical. 

%% the number of entities (classes, individuals etc) in the ontology. 
\newcommand{\OmnEntityNoSet}[1]{\gdef\OmnEntityNo{#1}}
\OmnEntityNoSet{0}

%% the file name
\newcommand{\OmnEntityFileNameSet}[1]{\gdef\OmnEntityFileName{#1}}
\OmnEntityFileNameSet{Unknown}

%% do we have a header?
\newcommand{\OmnEntitySetHeader}[1]{\gdef\OmnEntityHeaderNo{#1}}
\OmnEntitySetHeader{0}

%% Number of object properties
\newcommand{\OmnEntitySetObjectProperty}[1]{\gdef\OmnEntityObjectPropertyNo{#1}}
\OmnEntitySetObjectProperty{0}

%% number of classes
\newcommand{\OmnEntitySetClass}[1]{\gdef\OmnEntityClassNo{#1}}
\OmnEntitySetClass{0}

%% number of individuals.
\newcommand{\OmnEntitySetIndividual}[1]{\gdef\OmnEntityIndividualNo{#1}}
\OmnEntitySetIndividual{0}

%% number of data properties
\newcommand{\OmnEntitySetDataProperty}[1]{\gdef\OmnEntityDataPropertyNo{#1}}
\OmnEntitySetDataProperty{0}


%% put in the summary. 
\newcommand{\omnsummary}{
OMN from \texttt{\OmnEntityFileName{}} which contains \OmnEntityNo{} entities,
consisting of:
\begin{itemize}
 \item \OmnEntityHeaderNo{} header(s)
 \item \OmnEntityClassNo{} class(es)
 \item \OmnEntityObjectPropertyNo{} object property(s)
 \item \OmnEntityDataPropertyNo{} data property(s)
 \item \OmnEntityIndividualNo{} individual(s)
\end{itemize}
}


%% I've chosed to use _index.spt and so on here. For reasons that I didn't
%% understand, if I used the same file stem as the .omn file, latex read the
%% wrong file in. 
\newcommand{\omndoc}[1]{\input{#1_index.spt}\input{#1_summary.spt}}
\newcommand{\omndocfile}{\texttt{\OmnEntityFileName}}

%% this bit don't work.
%%\newenvironment{omn}
%%{\begin{lstlisting}[language=omn]}
%%{\end{lstlisting}}



